using MediatR;

namespace RAG.Domain.Entities;

public class EntityBase
{
    //ID
    public Guid Id { get; set; }
    //创建时间
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    //更新时间
    public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
    //创建人
    public Guid CreatedBy { get; set; } = Guid.Empty;
    //更新人
    public Guid UpdatedBy { get; set; } = Guid.Empty;
    
    // 领域事件集合
    private readonly List<INotification> _domainEvents = new();
    
    // 领域事件集合（只读）
    public IReadOnlyCollection<INotification> DomainEvents => _domainEvents.AsReadOnly();
    
    // 添加领域事件
    protected void AddDomainEvent(INotification domainEvent)
    {
        _domainEvents.Add(domainEvent);
    }
    
    // 清除领域事件
    public void ClearDomainEvents()
    {
        _domainEvents.Clear();
    }
}   